package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.data.interfaces.IFenSiInterface;
import com.itboye.mengwu.data.model.FenSiBean;
import com.itboye.mengwu.data.model.MessageXiTongBean;
import com.itboye.mengwu.data.model.MessgeBean;
import com.itboye.mengwu.data.model.WodeZengSongShangPingBean;

public class FenSiRepository extends BaseNetRepository implements
		IFenSiInterface<FenSiBean> {

	public static final String FenSi = "BY_BbsUserCenter_focusMe";// 粉丝列表
	public static final String Guanzhu = "BY_BbsUserCenter_myFocus";// 关注列表

	public static final String Message = "BY_Message_query";// 系统通知BY_Message_query

	public static final String ShopZengSong = "BY_Product_listGift";// 商品赠送

	public FenSiRepository(ICompleteListener listener) {
		super(listener);
	}

	@Override
	public void add(FenSiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(FenSiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(FenSiBean model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<FenSiBean>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", model.getUid());
		params.put("page_size", model.getPagesize());
		params.put("page_no", model.getPageno());
		// 目前最简化调用
		// START
		(new Builder<FenSiBean>())
				.setTypeVerParamsAndReturnClass(Guanzhu, apiVer, params, type)
				.requestListener(
						new BaseSuccessReqListener<FenSiBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void getInfo(FenSiBean model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<FenSiBean>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", model.getUid());
		params.put("my_uid", model.getUid());
		params.put("page_no", model.getPageno());
		// 目前最简化调用
		// START
		(new Builder<FenSiBean>())
				.setTypeVerParamsAndReturnClass(FenSi, apiVer, params, type)
				.requestListener(
						new BaseSuccessReqListener<FenSiBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public List<FenSiBean> queryYouHuiQuan(FenSiBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void systemMessage(String uid, String msgType, int pageNo) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<MessageXiTongBean>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("msg_type", msgType);
		params.put("page_no", pageNo);
		// 目前最简化调用
		// START
		(new Builder<MessageXiTongBean>())
				.setTypeVerParamsAndReturnClass(Message, apiVer, params, type)
				.requestListener(
						new BaseSuccessReqListener<MessageXiTongBean>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void ShopZengSong(String uid, String page_no, String page_size) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<WodeZengSongShangPingBean>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("page_no", page_no);
		params.put("page_size", page_size);

		// 目前最简化调用
		// START
		(new Builder<WodeZengSongShangPingBean>())
				.setTypeVerParamsAndReturnClass(ShopZengSong, apiVer, params,
						type)
				.requestListener(
						new BaseSuccessReqListener<WodeZengSongShangPingBean>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void onMeShouDao(String to_uid, String page_no, String page_size) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<WodeZengSongShangPingBean>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("to_uid", to_uid);
		params.put("page_no", page_no);
		params.put("page_size", page_size);
		// 目前最简化调用
		// START
		(new Builder<WodeZengSongShangPingBean>())
				.setTypeVerParamsAndReturnClass(ShopZengSong, apiVer, params,
						type)
				.requestListener(
						new BaseSuccessReqListener<WodeZengSongShangPingBean>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

}
